package com.singfan.app.controller.model;

import com.singfan.app.controller.model.response.partial.BarberPartial;
import com.singfan.app.controller.model.response.partial.CouponPartial;
import com.singfan.app.controller.model.response.partial.HairstylePartial;
import com.singfan.app.controller.model.response.partial.ShopSummaryPartial;
import com.singfan.core.dao.database.config.ConfigDataManager;
import com.singfan.core.dao.database.model.Barber;
import com.singfan.core.dao.database.model.BarberHairstyle;
import com.singfan.core.dao.database.model.CustomerCoupon;
import com.singfan.core.dao.database.model.ShopHair;

/**
 * Author: hansonghe
 * Date: 2015-08-24 16:43
 * Desc:
 */
public class HttpModelConverter {
    public static BarberPartial barber2BarberPartial(Barber barber){
        BarberPartial barberPartial = new BarberPartial();

        barberPartial.setBarberID(barber.getId());
        barberPartial.setBarberAvatar(barber.getAvatar());
        barberPartial.setBarberName(barber.getNickName());
        barberPartial.setShopId(barber.getShopId());
        barberPartial.setShopName(barber.getMasterShopName());
        if (barber.getPositionId() > 0){
            barberPartial.setBarberTitle(ConfigDataManager.getInstance().getBarberPositionConfig(barber.getPositionId()).getPosition());
        }
        else {
            barberPartial.setBarberTitle("");
        }

        barberPartial.setMaster(barber.getPositionId() == 3);
        barberPartial.setDistance(0);
        barberPartial.setOrderCount(barber.getOrderCount());
        barberPartial.setGoodCommentCount(barber.getFavorableCommentCount());
        barberPartial.setHonorLevel(barber.getHonor());
        barberPartial.setPrice(barber.getHairCutRealPrice());
        return barberPartial;
    }

    public static ShopSummaryPartial shopHair2ShopSummaryPartial(ShopHair shopHair){
        ShopSummaryPartial shopSummaryPartial = new ShopSummaryPartial();

        shopSummaryPartial.setShopID(shopHair.getShopId());
        shopSummaryPartial.setShopImgUrl(shopHair.getPreferredImg());
        shopSummaryPartial.setShopMasterName(shopHair.getMasterShopName());
        shopSummaryPartial.setShopSlaveName(shopHair.getSlaveShopName());
        shopSummaryPartial.setBarberCount(shopHair.getBarberCount());
        shopSummaryPartial.setOrderCount(shopHair.getOrderCount());
        shopSummaryPartial.setHonorLevel(shopHair.getHonor());

        return shopSummaryPartial;
    }

    public static HairstylePartial barberHairstyle2HairstylePartial(BarberHairstyle barberHairstyle){
        HairstylePartial hairstylePartial = new HairstylePartial();

        hairstylePartial.setHairstyleId(barberHairstyle.getId());
        hairstylePartial.setHairstyleImgUrl(barberHairstyle.getPreferredImg());
        hairstylePartial.setHairstyleName(barberHairstyle.getHairstyleName());
        hairstylePartial.setHairstylePrice(barberHairstyle.getPrice());
        hairstylePartial.setOrderCount(barberHairstyle.getOrderCount());
        hairstylePartial.setCollectCount(barberHairstyle.getCollectCount());
        hairstylePartial.setStatus(barberHairstyle.getStatus());

        return hairstylePartial;
    }

    public static CouponPartial CustomerCoupon2CouponPartial(CustomerCoupon customerCoupon){
        CouponPartial couponPartial = new CouponPartial();

        couponPartial.setCouponId(customerCoupon.getId());
        couponPartial.setExpirationTime(customerCoupon.getExpiredTime().getTime());
        couponPartial.setAmount(customerCoupon.getAmount());
        couponPartial.setShopId(customerCoupon.getShopId());
        couponPartial.setShopMasterName(customerCoupon.getShopMasterName());
        couponPartial.setShopSlaveName(customerCoupon.getShopSlaveName());
        couponPartial.setCondition(customerCoupon.getPriceCondition());

        return couponPartial;
    }
}
